<?php
     class manageModel extends Model{
	    //新闻管理的模型
	    //获取新闻列表
	    public function getAll(){
		   $rs=$this->db->fetchAll('select * from news where pid=0');
		   return $rs;
		}
		//获取新闻的内容 修改新闻
		public function getById(){
			$id=$_GET['id'];
			$sql="select * from news where id='{$id}'";
			$rs=$this->db->fetchRow($sql);
			return $rs;
		}
		//修改新闻
		public function update(){
			$id=$_POST['id'];
			$title=$_POST['title'];
		    $date=$_POST['date'];
    	    $source=$_POST['source'];
	        $reporter=$_POST['reporter'];
	        $content=$_POST['content'];
            $editor=$_POST['editor'];
			$sql="update news set title='{$title}',source='{$source}',date='{$date}',reporter='{$reporter}',content='{$content}',editor='{$editor}' where id='{$id}'";
			return $this->db->query($sql);
		}
		//删除新闻的方法
		public function delete(){
			$id=$_GET['id'];
			$sql="DELETE FROM `news` WHERE `news`.`id` ='{$id}'";
			$rs=$this->db->query($sql);
			return $rs;
		}
	 } 
?>